﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using _1141092_1141105_ToiecTest.Resources;
using _1141092_1141105_ToiecTest.DTO;
using System.Collections.ObjectModel;

using System.Data;
using SQLite;
using System.IO;
using Windows.Storage;

namespace _1141092_1141105_ToiecTest
{
    public partial class MainPage : PhoneApplicationPage
    {

        public static string DB_PATH = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "toeicDB.db"));
        private SQLiteConnection dbConn;
        private void CreateDatabase()
        {
            dbConn = new SQLiteConnection(DB_PATH);
            /// Create the table Task, if it doesn't exist.
            dbConn.CreateTable<CauHoi>();
            /// Retrieve the task list from the database.
            List<CauHoi> retrievedTasks = dbConn.Table<CauHoi>().ToList<CauHoi>();
            
        }
        public MainPage()
        {

            InitializeComponent();
            CreateDatabase();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            Button clickedButton = sender as Button;
            switch (clickedButton.Name)
            {
                case "btnListenning":
                    NavigationService.Navigate(new Uri("/ListenningPage.xaml", UriKind.Relative));
                    break;
                case "btnReading":
                    NavigationService.Navigate(new Uri("/ReadingPage.xaml", UriKind.Relative));
                    break;
                case "btnSetting":
                    NavigationService.Navigate(new Uri("/PhotoGraphsPage.xaml", UriKind.Relative));
                    break;
            }
        }

        private void btn_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Image clicked = sender as Image;
            switch (clicked.Name)
            {
                case "btnListenning":
                    NavigationService.Navigate(new Uri("/ListenningPage.xaml", UriKind.Relative));
                    break;
                case "btnReading":
                    NavigationService.Navigate(new Uri("/Gui/ReadingPage.xaml", UriKind.Relative));
                    break;
                case "btnSetting":
                    NavigationService.Navigate(new Uri("/PhotoGraphsPage.xaml", UriKind.Relative));
                    break;
            }
        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}